﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for DonDatHangBUS
/// </summary>
public class DonDatHangBUS
{
	private DonDatHangDAO objOrdersDAO;
    public DonDatHangBUS(string strPath)
    {
        objOrdersDAO = new DonDatHangDAO(strPath);
    }
    public DataSet CreateOrder(String shoppingCartId, Guid idNguoiDung)
    {
        DataSet ds;
        try
        {
            ds = objOrdersDAO.CreateDonDatHang(shoppingCartId, idNguoiDung);
            return ds;
        }
        catch (System.Exception e)
        {
            throw new Exception(e.Message, e.InnerException);
        }
    }
    public DataSet GetByRecentDonDatHang(int count)
    {
        DataSet ds;
        try
        {
            ds = objOrdersDAO.GetByRecentDonDatHang(count);
            return ds;
        }
        catch (System.Exception e)
        {
            throw new Exception(e.Message, e.InnerException);
        }
    }

    public DataSet GetByDateDonDatHang(DateTime StartDate, DateTime EndDate)
    {
        DataSet ds;
        try
        {
            ds = objOrdersDAO.GetByDateDonDatHang(StartDate, EndDate);
            return ds;
        }
        catch (System.Exception e)
        {
            throw new Exception(e.Message, e.InnerException);
        }
    }
    public DataSet ThongKeDoanhThu(DateTime StartDate, DateTime EndDate)
    {
        DataSet ds;
        try
        {
            ds = objOrdersDAO.ThongKeDoanhThu(StartDate, EndDate);
            return ds;
        }
        catch (System.Exception e)
        {
            throw new Exception(e.Message, e.InnerException);
        }
    }

    public DataSet GetUnverifiedUncanceledDonDatHang()
    {
        DataSet ds;
        try
        {
            ds = objOrdersDAO.GetUnverifiedUncanceledDonDatHang();
            return ds;
        }
        catch (System.Exception e)
        {
            throw new Exception(e.Message, e.InnerException);
        }
    }

    public DataSet GetVerifiedUncompletedDonDatHang()
    {
        DataSet ds;
        try
        {
            ds = objOrdersDAO.GetVerifiedUncompletedDonDatHang();
            return ds;
        }
        catch (System.Exception e)
        {
            throw new Exception(e.Message, e.InnerException);
        }
    }

    public DataSet GetCompletedDonDatHang()
    {
        DataSet ds;
        try
        {
            ds = objOrdersDAO.GetCompletedDonDatHang();
            return ds;
        }
        catch (System.Exception e)
        {
            throw new Exception(e.Message, e.InnerException);
        }
    }

    public DataSet GetInfoDonDatHang(int id)
    {
        DataSet ds;
        try
        {
            ds = objOrdersDAO.GetInfoDonDatHang(id);
            return ds;
        }
        catch (System.Exception e)
        {
            throw new Exception(e.Message, e.InnerException);
        }
    }

    public DataSet GetDetailsDonDatHang(int id)
    {
        DataSet ds;
        try
        {
            ds = objOrdersDAO.GetDetailsDonDatHang(id);
            return ds;
        }
        catch (System.Exception e)
        {
            throw new Exception(e.Message, e.InnerException);
        }
    }

    public DataSet MarkVerifiedDonDatHang(int id)
    {
        DataSet ds;
        try
        {
            ds = objOrdersDAO.MarkVerifiedDonDatHang(id);
            return ds;
        }
        catch (System.Exception e)
        {
            throw new Exception(e.Message, e.InnerException);
        }
    }
    public DataSet MarkCompletedDonDatHang(int id)
    {
        DataSet ds;
        try
        {
            ds = objOrdersDAO.MarkCompletedDonDatHang(id);
            return ds;
        }
        catch (System.Exception e)
        {
            throw new Exception(e.Message, e.InnerException);
        }
    }
    public DataSet MarkCanceledDonDatHang(int id)
    {
        DataSet ds;
        try
        {
            ds = objOrdersDAO.MarkCanceledDonDatHang(id);
            return ds;
        }
        catch (System.Exception e)
        {
            throw new Exception(e.Message, e.InnerException);
        }
    }

    public DataSet UpdateDonDatHang(DonDatHangDTO ddh, int type)
    {
        DataSet ds;
        try
        {
            ds = objOrdersDAO.UpdateDonDatHang(ddh, type);
            return ds;
        }
        catch (System.Exception e)
        {
            throw new Exception(e.Message, e.InnerException);
        }
    }

    public Boolean InitDonDatHangInfo(DonDatHangDTO ddh)
    {
        return objOrdersDAO.InitDonDatHangInfo(ddh);
    }

    public DataSet LichSuGiaoDich(Guid idNguoiDung)
    {
        DataSet ds;
        try
        {
            ds = objOrdersDAO.LichSuGiaoDich(idNguoiDung);
            return ds;
        }
        catch (System.Exception e)
        {
            throw new Exception(e.Message, e.InnerException);
        }
    }
}
